<script src="../media/system/js/mootools-core.js" type="text/javascript"></script>
<script src="../media/system/js/core.js" type="text/javascript"></script>
<?php
    $aut = new bgAuthorize();
 ?>
<script type="text/javascript" src="../media/system/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../media/system/js/jQuery.vietvang.validate.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$('#adminForm').validate({
			});
		});
</script>
<form action="index.php?option=com_center" method="post" name="adminForm" id="adminForm">
	 <?php
     //check user group
           $aut=new bgAuthorize();
          // check  user login
           $group=$aut->getUserGroup();
           $u=JFactory::getUser();
           $u_ocba= $u->USEM_OCBA_CODE;
           if($group!=11)
           {
    ?>
    <fieldset id="filter-bar">   
    <div style="border: solid 1px #ccc; padding: 10px;border-radius: 5px;">
            <table border=0 id="table-center-club-search" style="width: 1000px;margin:0px auto">
                <tr>
                    <td style="width: 14%;line-height:20px" class="text-align-right">センター・クラブ種別</td>
                    <td style="width: 30%;">
                        <?php
                            $filter_typecc = $this->list['filter_typecc'];
                        ?>
                        <select id="filter_typecc" name="filter_typecc" class="inputbox medium">
                            <option value="0">指定しない</option>
                            <option value="1" <?php $temp = isset($filter_typecc) ? $filter_typecc : false;if ($temp == 1) { echo ' selected="selected"';} ?> >センター</option>
                            <option value="2" <?php $temp = isset($filter_typecc) ? $filter_typecc : false;if ($temp == 2) { echo ' selected="selected"';} ?> >クラブ</option>
                        </select>
                    </td>
                    <td class="text-align-right" style="width: 14%;line-height:20px">センター・クラブ名</td>

                    <td>
                        <input type="text" name="filter_namecc" id="filter_namecc" value="<?php echo $this->list['filter_namecc']; ?>" class="inputbox medium" />
                    </td>
                </tr>
                <tr>
                    <td class="text-align-right" style="line-height:20px">都道府県</td>
                    <td>
                        <select name="filter_pref" id="filter_pref"  class="inputbox medium">
                          <option value="0" selected="selected">指定しない</option>
                          <?php
                            $pref_search = $this->list['filter_pref'];
                            foreach($this->listpref as $value){
                          ?>
                          <option value="<?php echo $value->PREF_CODE; ?>" <?php $temp = isset($pref_search) ? $pref_search : false;if ($temp == $value->PREF_CODE) { echo ' selected="selected"';} ?> >
                          <?php echo $value->PREF_NAME; ?></option>
                          <?php
                            }
                          ?>
                       </select>
                    </td>
                    <td class="text-align-right" style="line-height:20px">センター・クラブコード</td>
                    <td>
                        <input type="text" name="filter_idcc" id="filter_idcc" value="<?php echo $this->list['filter_idcc']; ?>" class="inputbox medium" />
                    </td>
                </tr>
                <tr>
                    
                </tr>
                <tr>
                    
                </tr>
                <tr>
                    <td class="text-align-right" style="line-height:20px">設立年度</td>
                    <td>
                        <input type="text" vvName="number" name="filter_year" id="filter_year" value="<?php echo $this->list['filter_year']; ?>" class="inputbox medium">
                        <span name="msg_error"></span>
                    </td>
                    <td class="text-align-right" style="line-height:28px;font-size: 1.091em;">クラブ種別 </td>
                    <td>
                       <select name="filter_clubtype" id="filter_clubtype"  class="inputbox medium">
                          <option value="0" selected="selected">指定しない</option>
                          <?php
                            $club_search = $this->list['filter_clubtype'];
                            foreach($this->listclub as $value){
                          ?>
                          <option value="<?php echo $value->CLUB_CODE; ?>" <?php $temp = isset($club_search) ? $club_search : false;if ($temp == $value->CLUB_CODE) { echo ' selected="selected"';} ?> >
                          <?php echo $value->CLUB_NAME; ?></option>
                          <?php
                            }
                          ?>
                          
                       </select>
                    </td>
                </tr>
                <tr>
                    <td class="text-align-right">施設種別 </td>
                    <td colspan="3">
                    <?php
                        $i = 0;
                        foreach($this->listfacitype as $key=>$value){
                            $i++;
                    ?>
                    <input type="checkbox" name="chb<?php echo $key; ?>" id="chb<?php echo $key; ?>" value="<?php echo $key; ?>" <?php if(isset($this->list['chb'.$key])){ echo 'checked="checked"'; } ?>  /><label for="chb<?php echo $key; ?>"><?php echo $value; ?></label>
                    
                    <?php
                            if($i==2){
                                $i = 0;
                                echo "</tr><tr><td></td><td colspan='3'>"; 
                            }    
                        }
                    ?>
                    </td>
                </tr>
                
                <tr>
                    
                </tr>
                <tr>
                    <td></td>
                    <td colspan="3" style="text-align: center;padding-left:300px;">
                        <button id="search" type="button" onclick="Joomla.submitbutton('search')">検索</button>
                        <button type="button" class="button" onclick="document.id('filter_typecc').value='0';document.id('filter_pref').value='0';
                        document.id('filter_namecc').value='';document.id('filter_idcc').value='';document.id('filter_year').value='';
                        <?php
                            foreach($this->listfacitype as $key=>$value){
                                
                        ?>
                            document.id('chb<?php echo $key; ?>').checked = false;
                        <?php } ?>
                        document.id('filter_clubtype').value='0';this.form.submit();">クリア</button>
                    </td>
                </tr>
            </table>
			
	</div>  
	</fieldset>
 <?php } ?>
    <div  webmemes_parsed="1">
         <!--<button class="float-left button" id="btncom_pgb" ><a style="text-decoration: none;" href="index.php?option=com_pgb">プール．体育館．艇庫作成．編集</a></button>-->
         <button class="float-left button" id="btncom_pgb" href="index.php?option=com_pgb" >プール・体育館・艇庫　作成・編集</button> 
			<div webmemes_parsed="1">
				<div class="toolbar-list" id="toolbar" webmemes_parsed="1">
                                    
                        <ul>
                        <?php if($aut->checkAdd()){ ?>
                        <li class="button" id="toolbar-new">
                            <a href="#" onclick="Joomla.submitbutton('add')" class="toolbar">
                                <span class="icon-32-new" webmemes_parsed="1">
                                </span>
                                作成
                            </a>
                        </li>
                        <?php
                         }
                        if($aut->checkEdit() || $aut->checkEditOwn()){
                        ?>
                        <li class="button" id="toolbar-edit">
                            <a href="#" onclick="if (document.adminForm.boxchecked.value==0){alert('編集対象のものを指定してから行ってください。');}else{ Joomla.submitbutton('edit')}" class="toolbar">
                                <span class="icon-32-edit" webmemes_parsed="1">
                                </span>
                                編集
                            </a>
                        </li>
                        <?php
                        }
                        if($aut->checkDelete()){
                        ?>
                        <li class="button" id="toolbar-delete">
                            <a href="#" onclick="if (document.adminForm.boxchecked.value==0){alert('編集対象のものを指定してから行ってください。');}else{ Joomla.submitbutton('remove')}" class="toolbar">
                                <span class="icon-32-delete" webmemes_parsed="1">
                                </span>
                                削除
                            </a>
                        </li>
                        <?php
                        }
                        if($aut->getUserGroup() == '8' || $aut->getUserGroup() == '9'){
                        
                        ?>
                        <li class="button" id="toolbar-csv">
                            <a href="#" onclick="Joomla.submitbutton('export_csv_ocba');document.id('task').value='';" class="toolbar">
                                <span class="icon-32-csv" webmemes_parsed="1">
                                </span>
                                CSV出力
                            </a>
                        </li>
                        <?php } ?>
                        </ul>
                        
                </div>
                        					
			</div>
	</div>
    <div class="clr"> </div>

	<table class="adminlist">
		<thead>
			<tr>
				<th width="1%">
                    <input type="checkbox" name="checkall-toggle" value="" title="Check All" onclick="Joomla.checkAll(this)"/>
				</th>
				<th width="15%">
					<label class="labelth" >番号</label>			
                </th>
				<th width="20%">
					<label class="labelth">名称</label>				
                </th>
				<th width="23%">
					<label class="labelth">所在地</label>	
                </th>
				<th width="25%">
					<label class="labelth">連絡先</label>			
                </th>
                <th width="9%">
					<label class="labelth">同期済/未同期</label>		
                </th>
                <th width="9%">
					<label class="labelth">公開済/一時保存中</label>
                </th>
          
				
			</tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="15">
				    <?php echo $this->pagination->getListFooter(); ?>	
                </td>
            </tr>
		</tfoot>
		<tbody>
            <?php 
            $rows = $this->rows;
            if($rows != null){
                foreach($rows as $k=>$row){
            ?>              
    		  <tr class="row<?php echo $k%2?>">
    			<td class="center">
                    <input type="checkbox" id="cb<?php echo $row->OCBA_CODE ?>" name="cid[]" value="<?php echo $row->OCBA_CODE ?>" onclick="Joomla.isChecked(this.checked);"/>
                </td>
    			<td class="center"><a href="#" onclick="document.id('cb<?php echo $row->OCBA_CODE ?>').checked=true;Joomla.submitbutton('edit');"><?php echo $row->OCBA_CODE; ?></a></td>
    			<td class="left"><a href="#" onclick="document.id('cb<?php echo $row->OCBA_CODE ?>').checked=true;Joomla.submitbutton('edit');"><?php echo $row->OCBA_NAME; ?></a></td>
                <td class="left"><?php echo $row->OCBA_ADD1; ?></td>
                <td class="left"><?php if(!empty($row->OCBA_TEL)){ ?>Tel: <?php echo $row->OCBA_TEL; } if(!empty($row->OCBA_FAX)){ ?> - Fax: <?php echo $row->OCBA_FAX; } ?></td>
                <td class="center"><?php if($row->OCBA_DBSY == 1){ echo "同期済"; }else{ echo "未同期"; } ?></td>
                <td class="center"><?php if($row->OCBA_WEBF == 1){ echo "公開済"; }else{ echo "一時保存中"; } ?></td>
               
    		  </tr>
            <?php
                }
            }else{
            ?>
                <tr>
                    <td class="center" colspan="7">データは見つかりませんでした</td>
                </tr>
            <?php    
            }
             ?>
		</tbody>
	</table>
    <!-- <input type="submit" value="同期" style="width: 75px;float:right;" onclick="Joomla.submitbutton('dongbo_csv_ocba');document.id('task').value='';"/> -->
	<div>
		<input type="hidden" id="task" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
   </div>
</form>
<script>
Joomla.submitbutton = function(task){
    if(task == 'remove'){
        if(!confirm('選択したデータを削除します。よろしいですか？')){
            return false;
        }
    }
    Joomla.submitform(task, document.getElementById('adminForm'));
       
 }
</script>